package tool.zyk.spring.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import tool.zyk.invoke.ReflectExecutor;
import tool.zyk.invoke.ReflectExecutorFactory;

/**
 * @author feite.zyk
 * @time 2024/2/4 11:49
 * @description
 */
@Slf4j
public class SpringReflectExecutorFactory implements ReflectExecutorFactory, ApplicationContextAware {
    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SpringReflectExecutorFactory.applicationContext = applicationContext;
    }

    @Override
    public ReflectExecutor getExecutor() {
        return applicationContext.getBean(ReflectExecutor.class);
    }
}
